package com.ph.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.ph.entity.MemberInfo;
import com.ph.util.SessionUtil;

/**
 * 
* @ClassName: LoginInterceptor  
* @Description: 拦截需要登录的请求 
* @author tony  
* @date 2017年3月29日  
*
 */
public class LoginInterceptor extends HandlerInterceptorAdapter {

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object obj) throws Exception {
		HttpSession session = request.getSession();
		if(session != null){
			Object value = session.getAttribute(SessionUtil.getKey());
			if(value instanceof MemberInfo){
				return true;
			}
		}
		response.sendRedirect("/member/loadlogin");
		return false;
	}

}
